/**
 * DesignMacro.h
 * Coyright (c) 2009 Xiaofeng Gu. All Rights Reserved.
 * Author : Xiaofeng Gu
 *
 * Creation Data : 2009/06/11
 */
#pragma once

#include "ProcessDraft.h"

#define DECALRE_INTERFACE_PART(_Interface) \
	virtual HRESULT _Interface() \


#define DECLARE_BASE_GINTERFACE(CCellProduction) \
class CCellProduction \
{ \
public: \
	CCellProduction() {} \
	virtual ~CCellProduction() {} \

#define GINTERFACE_BASE_PART(_Interface) \
	DECALRE_INTERFACE_PART(_Interface) { return S_OK; } \

#define END_BASE_DECLARE \
};

#define DECLARE_GINTERFACE(CProcessDistributor, CGeneralDesign) \
class CProcessDistributor : public CGeneralDesign \
{ \
private: \
	CGeneralDesign*			m_pNextProcess; \
	CProcessDraft*		m_pDesignerData; \
public: \
	CProcessDistributor(CGeneralDesign* pNextPorcess, CProcessDraft* pDesignData) \
	: m_pNextProcess(pNextPorcess), \
	  m_pDesignerData(pDesignData) {} \
	virtual ~CProcessDistributor() \
	{ \
	if (NULL == m_pNextProcess) \
	{ \
		delete m_pDesignerData; \
		m_pDesignerData = NULL; \
	} \
	delete m_pNextProcess; \
	m_pNextProcess = NULL; \
	} \
	template<class T> \
	T*		GetBlockInfo(CString strInterName) \
	{ \
		IObjectBlock* pBlock = m_pDesignerData->GetBlock(strInterName); \
		if (pBlock == NULL) return NULL; \
		CObjectBlock<T>* pInfo = dynamic_cast<CObjectBlock<T>*>(pBlock); \
		if (pInfo != NULL) \
			return pInfo->GetBlockInfo(); \
		else \
			return NULL; \
	} \
	template<class T> \
	HRESULT	AddBlockInfo(CString strInterName, T* pBlockInfo, \
	bool bAutoFree, bool bPersistence) \
	{ \
		IObjectBlock* pBlock = new CObjectBlock<T>(pBlockInfo, bAutoFree, bPersistence); \
		return m_pDesignerData->AddBlock(strInterName, pBlock); \
	} \
public: \

#define GINTERFACE_PART(_Interface) \
	DECALRE_INTERFACE_PART(_Interface) \
	{ if (m_pNextProcess != NULL) \
			return m_pNextProcess->_Interface(); \
	  else \
			return S_OK; } \

#define END_DECLARE \
};